#include "minutelisten.h"
#include "log.h"




MinuteListen::MinuteListen()
{

}

MinuteListen::~MinuteListen()
{

}

void MinuteListen::OnTick()
{
    m_tick++;
    for (auto& item : m_on_tick)
    {
        try
        {
            item.second(m_tick);
        }
        catch(const std::exception& e)
        {
            log_error("tag:%s,exception:%s", item.first, e.what());
        }
        catch(...)
        {
            log_error("tag:%s catch unknown error", item.first);
        }
    }
}

void MinuteListen::Register(const char* tag, std::function<void(std::int64_t tick)> on_tick)
{
    m_on_tick[tag] = on_tick;
}












